package com.enzo.pcms.common.util;

import java.util.Locale;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

public class MsgUtil {
	private static Logger logger = Logger.getLogger(MsgUtil.class);
	private static WebApplicationContext cxt=null;
	private static MsgUtil util = null;
	private static final Object obj = new Object();

	private MsgUtil() {
		cxt=ContextLoader.getCurrentWebApplicationContext();
	}
	
	static {
		if (util == null) {
			synchronized (obj) {
				if (util == null) {
					util = new MsgUtil();
				}
			}
		}
	}
	public static String getValue(String name) {
		return cxt.getMessage(name, null, Locale.getDefault());
	}
	
	public static String getValue(String name, Object[] objs) {
		return cxt.getMessage(name, objs,Locale.getDefault());
	}
	
	public static String getValue(String name, Object[] objs,Locale locale) {
		return cxt.getMessage(name, objs,locale);
	}

}
